home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Utilities / System 7 / ChooserHack / ChooserHackGlue.a < prev    next >
Text File  |  1993-06-15  |  7KB  |  319 lines

  1. ;
  2. ;    File:        ChooserHackGlue.a
  3. ;
  4. ;    Contains:    Patches to call routines in ChooserHack.c 
  5. ;
  6. ;    Written by:    Nick Kledzik 
  7. ;
  8. ;    Date:        June 93
  9. ;    
  10. ;    For:        MacHack 93
  11. ;
  12. ;
  13.  
  14.             CASE    ON
  15.  
  16.             include    'Traps.a'
  17.             include    'SysEqu.a'
  18.  
  19.  
  20. INITStart    PROC    EXPORT
  21.  
  22.             IMPORT    DoInstall
  23.             
  24.             lea        INITStart,a0
  25.             _RecoverHandle , sys
  26.             _HLock
  27.             move.l    a0,-(sp)
  28.             _DetachResource
  29.                         
  30.             bra        DoInstall
  31.             ENDP
  32.             
  33.  
  34. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  35. ;
  36. ; Patch to _HFSDispatch 
  37. ;
  38. ; Use to catch the Finder enumerating the items in a folder.  
  39. ; Records the last folder the Finder enumerated (for use by SetWTitle patch).
  40. ;
  41. ;
  42. HFSPatch    PROC    EXPORT    
  43.             IMPORT    SYNCSPECIALFOLDER
  44.             
  45.             cmp.w    #9,d0                    ; only want D0.W = 9 (GetCatInfo)
  46.             bne.s    @goOld2
  47.             cmp.l    #'nick',32(a0)            ; don't want to recurse
  48.             beq.s    @goOld2
  49.             tst.w    28(a0)                    ; only want ioFDirIndex(A0) = 0
  50.             bne.s    @goOld2
  51.             move.l    $0910,d0
  52.             cmp.l    #$0646696E,d0            ; only want to catch Finder calls
  53.             bne.s    @goOld
  54.             pea        ret                        ; fake JSR to old HFS dispatch to tail patch
  55. @goOld
  56.             moveq    #9,d0
  57. @goOld2
  58.             move.l    oldHFSDispatch,-(sp)
  59.             rts
  60.             
  61.             EXPORT    oldHFSDispatch
  62. oldHFSDispatch    
  63.             dc.l    0
  64.             EXPORT    lastVRefNum, lastName
  65. lastVRefNum    dc.w    0
  66. lastParID    dc.l    0
  67. lastName    ds.b    32
  68. ret
  69.             tst.w    d0
  70.             bne.s    @done                    ; do nothing if error
  71.             btst    #4,30(a0)                ; only care if a directory was found (ioFlAttrib bit 4)
  72.             beq.s    @done
  73.             btst    #0,84+9(a0)                ; only care if it is one of my special folders
  74.             beq.s    @done
  75.             
  76.             movem.l    a0-a1/d0,-(sp)
  77.             lea        lastVRefNum,a1            ; copy info about what folder Finder was examining
  78.             move.w    22(a0),(a1)+
  79.             move.l    100(a0),(a1)+
  80.             move.l    18(a0),a0
  81.             moveq    #(32/4)-1,d0
  82. @loop        move.l    (a0)+,(a1)+
  83.             dbra    d0,@loop
  84.             movem.l    (sp)+,a0-a1/d0
  85. @done        rts    
  86.  
  87.  
  88.                 
  89. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  90. ;
  91. ; Patch to _SetWTitle 
  92. ;
  93. ; Use to catch the Finder creating a window.  
  94. ; If the Finder is creating a window with the same name as the 
  95. ; last folder enumerated, then the Finder is opening a folder.
  96. ;
  97. WTitlePatch    PROC    EXPORT    
  98.             EXPORT    oldSetWTitle
  99.             IMPORT    SYNCSPECIALFOLDER
  100.             IMPORT    lastVRefNum, lastName
  101.             
  102.             move.l    $0910,d0
  103.             cmp.l    #$0646696E,d0            ; only want to catch Finder calls
  104.             bne.s    @done
  105.             move.l    4(SP),A0
  106.             lea        lastName,A1
  107.             moveq    #0,d0
  108.             move.b    (a0),d0
  109. @loop        move.b    (a1)+,d1
  110.             cmp.b    (a0)+,d1                ; see if set window title to last searched folder
  111.             bne.s    @done
  112.             subq.w    #1,d0
  113.             bpl.s    @loop
  114.             
  115.             lea        lastVRefNum,a0
  116.             move.w    (a0)+,-(sp)                ; SyncSpecialFolder( vRefNum, parID, name )
  117.             move.l    (a0)+,-(sp)
  118.             move.l    a0,-(sp)
  119.             bsr        SYNCSPECIALFOLDER
  120.     
  121. @done        move.l    oldSetWTitle,a0
  122.             jmp        (a0)
  123.  
  124. oldSetWTitle
  125.             dc.l    0
  126.             ENDP
  127.  
  128.  
  129.  
  130.  
  131.  
  132. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  133. ;
  134. ; Patch to _HOpenResFile
  135. ;
  136. ; Use to catch the Finder opening an alias file.
  137. ; Initially the files created by ChooserHack to represent network volumes
  138. ; are empty, but have the alias bit set.  If the Finder tries to get the 
  139. ; alias resource out of one, HOpenResFile will fail.  This patch catches
  140. ; that and calls OpenVolumeAliasFile to create the alias file
  141. ;
  142. ;
  143. HOpenRFPatch    PROC    EXPORT
  144.                 IMPORT    OPENVOLUMEALIASFILE, lastEventOpen
  145.  
  146.                 move.b    lastEventOpen,d0
  147.                 beq.s    @skip
  148.                 move.l    $0910,d0
  149.                 cmp.l    #$0646696E,d0            ; only want to catch Finder calls
  150.                 beq.s    @doit
  151. @skip            move.l    oldHOpenResFile,a0
  152.                 jmp        (a0)
  153.  
  154.  
  155. @doit            link    a6,#0
  156.                 subq    #2,sp
  157.                 move.w    18(a6),-(sp)
  158.                 move.l    14(a6),-(sp)
  159.                 move.l    10(a6),-(sp)
  160.                 move.w    8(a6),-(sp)
  161.                 move.l    oldHOpenResFile,a0
  162.                 jsr        (a0)                        ; tail patch HOpenResFile
  163.                 move.w    (sp)+,d0
  164.                 cmp.w    #-1,d0
  165.                 bne.s    @done                        ; only care if HOpenResFile returns -1
  166.                 move.w    #-39,d1
  167.                 cmp.w    $0A60,d1                    ; ResErr
  168.                 bne.s    @done                        ; only care if ResErr is -39
  169.                 
  170.                 subq    #2,sp
  171.                 move.w    18(a6),-(sp)
  172.                 move.l    14(a6),-(sp)
  173.                 move.l    10(a6),-(sp)
  174.                 jsr        OPENVOLUMEALIASFILE
  175.                 move.w    (sp)+,d0
  176.  
  177. @done            move.w    d0,20(a6)
  178.                 unlk    a6
  179.                 move.l    (sp)+,a0
  180.                 add        #12,sp
  181.                 jmp        (a0)
  182.                 
  183.  
  184.                 EXPORT    oldHOpenResFile
  185. oldHOpenResFile
  186.                 dc.l    0
  187.                 ENDP
  188.                 
  189.  
  190. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  191. ;
  192. ; Patch to jGNEfilter
  193. ;
  194. ; Use to catch the Finder opening an alias file.
  195. ; Unfortunately, the Finder tries to open alias files for reasons other
  196. ; than opening.  To have the HOpenResFile patch only effect the 
  197. ; Finder trying to open alias, this jGNEfilter remembers if the last user
  198. ; event was a double-click or Cmd-O.
  199. ;
  200. MyEventFilter    PROC    EXPORT
  201.                 movem.l    d0/a0,-(sp)
  202.                 move.w    evtNum(a1),d0
  203.                 
  204.         ; look for Cmd-O keydown        
  205.                 cmp.w    #keyDwnEvt,d0            
  206.                 bne.s    @notKey
  207.                 move.l    evtMessage(a1),d0
  208.                 cmp.b    #'o',d0
  209.                 bne.s    @clrFlag
  210.                 btst    #cmdKey,evtMeta(a1)
  211.                 beq.s    @clrFlag
  212. @setFlag        lea        lastEventOpen,a0
  213.                 st        (a0)
  214.                 bra.s    @done
  215.                 
  216.         ; look for double click        
  217. @notKey            cmp.w    #mButDwnEvt,d0
  218.                 bne.s    @notMouseDwn
  219.                 lea        lastMouseTicks,a0
  220.                 move.l    (a0),d0
  221.                 move.l    evtTicks(a1),(a0)
  222.                 add.l    DoubleTime,d0
  223.                 cmp.l    (a0),d0
  224.                 bhi.s    @setFlag                
  225.                 bra.s    @clrFlag
  226.     
  227.         ; look for update event
  228. @notMouseDwn    cmp.w    #updatEvt,d0
  229.                 bne.s    @done                ; update event clears flag
  230.                 
  231.  
  232. @clrFlag        lea        lastEventOpen,a0
  233.                 sf        (a0)                
  234. @done            movem.l    (sp)+,d0/a0
  235.                 move.l    oldjGNEFilter,-(sp)
  236.                 bne.s    @ok                        ; only call next filter if there is one
  237.                 addq    #4,sp
  238. @ok                rts
  239.  
  240.                 EXPORT    oldjGNEFilter, lastEventOpen
  241.  
  242. lastMouseTicks    dc.l    0
  243. oldjGNEFilter    dc.l    0
  244. lastEventOpen    dc.b    0
  245.                 ENDP
  246.  
  247.  
  248.  
  249.  
  250.  
  251. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  252. ;
  253. ; Install all the patches.
  254. ;
  255. InstallPatches    PROC    EXPORT
  256.             
  257.         ; install HFSDispatch patch
  258.                 IMPORT    HFSPatch, oldHFSDispatch
  259.                 move.w    #$060,d0
  260.                 _GetTrapAddress , newOS
  261.                 lea        oldHFSDispatch,a1
  262.                 move.l    a0,(a1)
  263.                 move.w    #$060,d0
  264.                 lea        HFSPatch,a0
  265.                 _SetTrapAddress , newOS
  266.                 
  267.                 
  268.         ; install SetWTitle patch
  269.                 IMPORT    WTitlePatch, oldSetWTitle
  270.                 move.w    #$011A,d0
  271.                 _GetTrapAddress , newTool
  272.                 lea        oldSetWTitle,a1
  273.                 move.l    a0,(a1)
  274.                 move.w    #$011A,d0
  275.                 lea        WTitlePatch,a0
  276.                 _SetTrapAddress , newTool
  277.                 
  278.         ; install HOpenResFile patch
  279.                 IMPORT    HOpenRFPatch, oldHOpenResFile
  280.                 move.w    #$001A,d0
  281.                 _GetTrapAddress , newTool
  282.                 lea        oldHOpenResFile,a1
  283.                 move.l    a0,(a1)
  284.                 move.w    #$001A,d0
  285.                 lea        HOpenRFPatch,a0
  286.                 _SetTrapAddress , newTool
  287.             
  288.         ; install jGNE filter
  289.                 IMPORT    MyEventFilter, oldjGNEFilter
  290.                 move.l    JGNEFilter,a0
  291.                 lea        oldjGNEFilter,a1
  292.                 move.l    a0,(a1)
  293.                 lea        MyEventFilter,a0
  294.                 move.l    a0,JGNEFilter
  295.                 
  296.                 rts
  297.                 ENDP
  298.  
  299.  
  300.  
  301.  
  302. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  303. ;
  304. ;  Glue to access globals 
  305. ;
  306. ;
  307. GetGlobals    PROC    EXPORT
  308.             lea        globals,a0
  309.             move.l    a0,d0
  310.             rts
  311.             
  312. globals        ds.b    6
  313.             ENDP
  314.             
  315.             
  316.             
  317.             
  318.             
  319.             END